<!DOCTYPE html>
<html>
<head>
    <title>referrerpolicy attribute on click</title>
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
</head>
<body>
    <!-- Test that the referrerpolicy does not apply to click event
         listeners. -->
    <a href="#"
       referrerpolicy="never" id="click-me"></a>
    <script>
        setup({single_test: true});

        var elem = document.getElementById("click-me");

        var xhr = new XMLHttpRequest;
        var xhrDone = (function () {
            if (xhr.readyState !== 4)
                return;

            assert_true(xhr.responseText.indexOf(
                "referrer-policy-attribute-onclick.html") !== -1);
            done();
        });

        elem.addEventListener("click", function (event) {
            done();
            event.preventDefault();
            xhr.open("GET", "resources/echo-referrer-header.php", true);
            xhr.onreadystatechange = xhrDone;
            xhr.send();
            return false;
        });

        elem.click();

    </script>
</body>
</html>
